<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 * 
 * Description of contacto
 *
 * @author Federico & Leonel
 */
class Protoweb_controller extends Controller {

  public function __construct() {
    parent::__construct();
  } // end of method __construct()


  /**
   * Test if user is logged
   *
   * @param string $url_error url to redirect if the User don't pass the test
   * @return User object if true, else redirects to login
   */
  protected function security($url_error='') {
    $user_id = $this->session->userdata('id');
    
    if ($user_id) 
      return ( new User($user_id) );
    else {
      if ( ! strlen($url_error))
        $url_error = base_url() . 'users/login/';
      redirect($url_error);
    }
  } // end of method security($url_error)


  protected function get_client() {
    $client_id = $this->session->userdata('client');

    if ($client_id) {
      return (new Client($client_id));
    }
    else
      redirect(base_url().'users/login/');
  }


  private function app_path() {
    return (BASEPATH . "application/");
  }

  private function config_path() {
    return ($this->app_path() . "config/");
  }

  private function controllers_path() {
    return ($this->app_path() . "controllers/");
  }

  private function models_path() {
    return ($this->app_path() . "models/");
  }

  private function views_path() {
    return ($this->app_path() . "views/");
  }

} // class Protoweb

/* End of file protoweb.php */
/* Location: ./system/application/controllers/protoweb.php */
